package com.training.java.core.pre15;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class CarImmutableDemo {

	public static void main(String[] args) {
		CarImmutable car1 = new CarImmutable("Ford", "Focus", 2013);
		CarImmutable car2 = new CarImmutable("Honda", "Accord", 2014);
		CarImmutable car3 = new CarImmutable("Benz", "E250", 2015);

		List cars = new ArrayList();

		cars.add(car1);
		cars.add(car2);
		cars.add(car3);

		// read from list

		Iterator carsIterator = cars.iterator();

		while (carsIterator.hasNext()) {

			CarImmutable aCarImmutable = (CarImmutable) carsIterator.next();

			System.out.println("Start printing CarImmutable details *******");

			System.out.println("Make = " + aCarImmutable.getMake());
			System.out.println("Model = " + aCarImmutable.getModel());
			System.out.println("Year = " + aCarImmutable.getYear());

			System.out.println("End printing CarImmutable details *******");

		}

	}

}
